package drds.server.route.parser.core;

import drds.server.route.parser.core.impl.DeleteParser;
import drds.server.route.parser.core.impl.InsertParser;
import drds.server.route.parser.core.impl.SelectParser;
import drds.server.route.parser.core.impl.UpdateParser;
import drds.server.sqlparser.sqlobject.statement.Statement;
import drds.server.sqlparser.sqlobject.statement.delete.DeleteStatement;
import drds.server.sqlparser.sqlobject.statement.insert.InsertStatement;
import drds.server.sqlparser.sqlobject.statement.query.SelectStatement;
import drds.server.sqlparser.sqlobject.statement.update.UpdateStatement;

public class ParserFactory {

	public static SqlParser create(Statement statement) {
		SqlParser parser = null;
		if (statement instanceof SelectStatement) {
			parser = new SelectParser();
		} else if (statement instanceof InsertStatement) {
			parser = new InsertParser();
		} else if (statement instanceof DeleteStatement) {
			parser = new DeleteParser();
		} else if (statement instanceof UpdateStatement) {
			parser = new UpdateParser();
		} else {
			throw new RuntimeException();
		}

		return parser;
	}

}
